import numpy as np
from gauss_legendre import gauss_legendre, gauss_legendre_scipy
from romberg import romberg


def f(x):
    return np.sin(2 * np.pi / x) / x ** 2


true_value = -3 / (4 * np.pi)

print(gauss_legendre(f, 1, 3, 4))
print(gauss_legendre(f, 1, 3, 4) - true_value)

print(romberg(f, 1, 3))
print(romberg(f, 1, 3) - true_value)

for m in range(2, 12):
    res = [m]
    for n in range(3, 8):
        res.append(abs(gauss_legendre_scipy(f, 1, 3, m, n) - true_value))
    print(res)
